// pages/find/find.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    banners:[],
    huayu:[],
    gufeng:[],
    oumei:[],
    dfSongList:[],
    dfData:[],
    xgData:[],
    xgSongList:[],
    ycData:[],
    ycSongList:[],
  },

  toPlayList:function(e){
    var id = e.currentTarget.dataset.id
    wx.navigateTo({
      url: '/pages/playlist/playlist?id=' + id,
    })
  },

  toSearch:function(){
    //回之前的页面
    wx.navigateTo({
      url: '/pages/search/search',
    })

    //回首页
    // wx.redirectTo({
    //   url: '/pages/search/search',
    // })
    //进入小程序任何界面
    // wx.reLaunch({
    //   url: 'url',
    //   success: (res) => {},
    //   fail: (res) => {},
    //   complete: (res) => {},
    // })
    //进入tarBar页面
    // wx.switchTab({
    //   url: 'url',
    //   success: (res) => {},
    //   fail: (res) => {},
    //   complete: (res) => {},
    // })
  },

  getBanner:function(){
    wx.request({
      url: 'http://127.0.0.1:3000/banner',
      success:(res) => {
        // console.log(res)
        var list = res.data.banners
        this.setData({
          banners:list
        })
      }
    })
  },

  getList:function(){
    //推荐歌单部分 古风 欧美 华语
    wx.request({
      url: 'http://127.0.0.1:3000/top/playlist?cat=&limit=8',
      success:(res) => {
        // console.log(res)
        var list = res.data.playlists
        this.setData({
          tuijian:list
        })
      }
    })
    wx.request({
      url: 'http://127.0.0.1:3000/top/playlist?cat=华语&limit=8',
      success:(res) => {
        // console.log(res)
        var list = res.data.playlists
        this.setData({
          huayu:list
        })
      }
    })
    wx.request({
      url: 'http://127.0.0.1:3000/top/playlist?cat=古风&limit=8',
      success:(res) => {
        // console.log(res)
        var list = res.data.playlists
        this.setData({
          gufeng:list
        })
      }
    })
    wx.request({
      url: 'http://127.0.0.1:3000/top/playlist?cat=欧美&limit=8',
      success:(res) => {
        // console.log(res)
        var list = res.data.playlists
        this.setData({
          oumei:list
        })
      }
    })

    //排行榜单 巅峰榜 新歌榜 原创榜
    wx.request({
      url: 'http://127.0.0.1:3000/playlist/detail?id=19723756',
      success:(res) => {
        // console.log(res)
        //数据
        var list = res.data.playlist
        // console.log(list)
        //歌曲列表
        var dfSongList = list.tracks
        // console.log(dfSongList)
        this.setData({
        dfData:list,
        dfSongList:dfSongList
        })
      }
    })
    //xinge
    wx.request({
      url: 'http://127.0.0.1:3000/playlist/detail?id=3779629',
      success:(res) => {
        // console.log(res)
        //数据
        var list = res.data.playlist
        //歌曲列表
        var xgSongList = list.tracks
        // console.log(xgSongList)
        this.setData({
        xgData:list,
        xgSongList:xgSongList
        })
      }
    })
    //原创
    wx.request({
      url: 'http://127.0.0.1:3000/playlist/detail?id=2884035',
      success:(res) => {
        // console.log(res)
        //数据
        var list = res.data.playlist
        //歌曲列表
        var ycSongList = list.tracks
        // console.log(ycSongList)
        this.setData({
        ycData:list,
        ycSongList:ycSongList
        })
      }
    })
  },

  
  toBiaoSheng:function(){
    var id = '19723756'
    wx.navigateTo({
      url: '/pages/playlist/playlist?id=' + id,
    })
  },
  toXinGe:function(){
    var id = '3779629'
    wx.navigateTo({
      url: '/pages/playlist/playlist?id=' + id,
    })
  },
  toYuanChuang:function(){
    var id = '2884035'
    wx.navigateTo({
      url: '/pages/playlist/playlist?id=' + id,
    })
  },

  toBiaoShengPlay:function(e){
    //歌曲id
    var id = e.currentTarget.dataset.id
    //列表id
    var listId = this.data.dfData.id
    wx.navigateTo({
      url: '/pages/play/play?id=' + id + '&listId=' + listId,
    })
  },
  toXinGePlay:function(e){
    //歌曲id
    var id = e.currentTarget.dataset.id
    //列表id
    var listId = this.data.xgData.id
    wx.navigateTo({
      url: '/pages/play/play?id=' + id + '&listId=' + listId,
    })
  },
  toYuanChuangPlay:function(e){
    //歌曲id
    var id = e.currentTarget.dataset.id
    //列表id
    var listId = this.data.ycData.id
    wx.navigateTo({
      url: '/pages/play/play?id=' + id + '&listId=' + listId,
    })
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    this.getBanner()
    this.getList()
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})